package src.entity;

import src.core.AudioManager;

public class Player {
    private final int id;
    private int x;
    private int y;
    private int life;
    private int score;

    public Player(int id) {
        this.id = id;
        this.x = 100;
        this.y = 100;
        this.life = 100;
        this.score = 0;
    }

    // Getters
    public int getId() {
        return id;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public int getLife() {
        return life;
    }

    public int getScore() {
        return score;
    }

    // Setters
    public void setX(int x) {
        this.x = x;
    }

    public void setY(int y) {
        this.y = y;
    }

    public void setLife(int life) {
        this.life = life;
    }

    public void setScore(int score) {
        this.score = score;
    }

    // 增加分数
    public void incrementScore() {
        this.score++;
    }

    // 减少生命值
    public void decreaseLife(int amount) {
        this.life = Math.max(0, this.life - amount);
    }

    public Bullet shoot(int x, int y, int id) {
        // 播放射击音效
        AudioManager.getInstance().playSoundEffect("shoot");
        return new Bullet(x + 30, y + 25, id);
    }
}
